home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 4 / The 640 Meg Shareware Studio CD-ROM Volume IV (Data Express)(1994).ISO / clang / 114_01.zip / BDSCIO.H next >
Text File  |  1993-06-01  |  6KB  |  145 lines

  1. /*
  2. The BDS C Standard I/O header file --  v1.41    October 14, 1980
  3.  
  4. This file contains global definitions, for use in all C
  5. programs in PLACE of (yechhh) CONSTANTS. Characteristics of
  6. your system such as video screen size, interface port numbers
  7. and masks, buffered I/O allocations, etc., should all be
  8. configured just once within this file. Any program which needs
  9. them should contain the preprocessor directive:
  10.  
  11.     #include "bdscio.h"
  12.  
  13. near the beginning. Go through and set all this stuff as soon
  14. as you get the package, and most terminal-dependent sample
  15. programs should run much better. Some games (such as STONE.C
  16. and RALLY.C), which were contributed and beyond the scope of
  17. my ablity (or patience) to generalize, may not bother to use
  18. the globals from this file, alas.
  19.  
  20. */
  21.  
  22.  
  23. /****   Some console (video) terminal characteristics:   *****/
  24.  
  25. #define TWIDTH    64    /* # of columns    */
  26. #define TLENGTH    16    /* # of lines    */
  27.  
  28. #define CSTAT    0x7E    /* Console status port    */
  29. #define CDATA    0x7F    /* Console data port    */
  30. #define CIMASK    0x80    /* Console input data ready mask   */
  31. #define COMASK    0x80    /* Console output data ready mask  */
  32. #define CAHI    1    /* Console status active high */
  33. #define CRESET    0    /* Status port needs to be reset  */
  34. #define CRESETVAL 0    /* If CRESET true, value to send */
  35.  
  36. #define CLEARS    ""    /* String to clear screen on console */
  37. #define INTOREV    ""    /* String to switch to reverse video */
  38. #define OUTAREV ""    /* String to switch OUT rev video  */
  39. #define CURSOROFF ""    /* String to turn cursor off    */
  40. #define CURSORON ""    /* String to turn cursor on    */
  41.  
  42. #define ESC    '\033'    /* Standard ASCII 'escape' character */
  43.  
  44.  
  45. /*****      Modem characteristics:      *****/
  46.  
  47. #define    MSTAT    2    /* Modem status port    */
  48. #define MDATA    3    /* Modem data port    */
  49. #define MIMASK    0x40    /* Modem input data ready mask    */
  50. #define MOMASK    0x80    /* Modem ready to send mask */
  51. #define MAHI    1    /* Modem status logic active high  */
  52. #define MRESET    0    /* Modem status port needs reset */
  53. #define MRESETVAL 0    /* If MRESET true, byte to send */
  54.  
  55.  
  56. /******    General purpose Symbolic constants:  *********/
  57.  
  58. #define BASE 0        /* Base of CP/M system RAM  */
  59. #define NULL 0        /* Used by some functions */
  60. #define EOF -1        /* Physical EOF  for I/O functions */
  61. #define ERROR -1    /* General "on error" return value */
  62. #define OK 0        /* General "no error" return value */
  63. #define CPMEOF 0x1a    /* CP/M End-of-text-file marker   */
  64. #define SECSIZ 128    /* Sector size for read/write calls */
  65. #define MAXLINE 135    /* Longest line of input expected */
  66. #define TRUE 1        /* general purpose true truth value */
  67. #define FALSE 0        /* general purpose false truth value */
  68.  
  69. /*****   Number of sectors to use for buffered I/O: *******
  70. The NSECTS symbol controls the compilation of the buffered
  71. I/O routines within STDLIB2.C, allowing each user to set the
  72. buffer size most convenient for his system, while keeping
  73. the numbers totally invisible to the C source programs using
  74. buffered I/O (via the BUFSIZ defined symbol.) For larger
  75. NSECTS, the disk I/O is faster...but more ram is taken up.
  76. Note that prior (pre 1.4) versions of the library functions
  77. were not set up to support this customizable buffer size,
  78. and always compiled as if NSECTS was 1 in this version. To
  79. change the buffer size allocation, follow these steps:
  80.  
  81.     1) Alter NSECTS to the desired value here in bdscio.h
  82.     2) Re-compile STDLIB1.C and STDLIB2.C
  83.     3) Use CLIB to combine STDLIB1.CRL and STDLIB2.CRL to make
  84.      a new DEFF.CRL.
  85.  
  86. Make sure you use declare all your I/O buffers with the a
  87. statement such as:
  88.     char buf_name[BUFSIZ];
  89.   instead of the older and now obsolete:
  90.       char buf_name[134];
  91.   (and always #include "bdscio.h" in your programs!)
  92.  ************************************************************/
  93.  
  94. #define NSECTS 8    /* Number of sectors to buffer  */
  95.  
  96. #define BUFSIZ (NSECTS * SECSIZ + 6 )    /* Don't touch this */
  97. struct _buf {                /* Or this...        */
  98.     int _fd;
  99.     int _nleft;
  100.     char *_nextp;
  101.     char _buff[NSECTS * SECSIZ];
  102. };
  103.  
  104.  
  105.  
  106. /*************************************************************
  107. If you plan to use the high-level storage allocation functions
  108. from the library ("alloc" and "free") then:
  109.  
  110. 1) Uncomment (enable) the "ALLOC_ON" definition, and comment
  111.    out the
  112.     "ALLOC_OFF" definition from this file.
  113. 2) Re-compile STDLIB1.C, and use CLIB to transfer "alloc"
  114.    and "free" into the DEFF.CRL library file.
  115. 3) THIS IS IMPORTANT!!! Include the statement:
  116.     _allocp = NULL;       /* initialize allocation pointer */
  117.    somewhere in your "main" function PRIOR to the first use
  118.    of the "alloc" function. DON'T FORGET THIS INITIALIZATION!!
  119.  
  120. Remember to include bdscio.h in ALL files of your C program.
  121.  
  122. The lack of static variables is the reason for this messiness.
  123. ************************************************************/
  124.  
  125. /* only ONE of these two lines should be uncommented */
  126.  
  127. #define ALLOC_OFF 1    /* disables storage allocation */
  128.  
  129. /*
  130. #define ALLOC_ON 1    /* enables storgage allocation */
  131. */
  132.  
  133.  
  134. #ifdef ALLOC_ON            /* if allocation enabled, */
  135.  
  136. struct _header  {
  137.     struct _header *_ptr;
  138.     unsigned _size;
  139.     };
  140.  
  141. struct _header _base;        /* declare external data */
  142. struct _header *_allocp;    /* used by alloc() and free()*/
  143.  
  144. #endif
  145.